Skip to content

Conversation

@virtuald
Copy link
Contributor

@virtuald virtuald commented Feb 17, 2021

Description

Suggested changelog entry:

Fix unchecked errors could potentially swallow signals/other exceptions

#endif
}

inline PyObject * dict_getitem(PyObject *v, PyObject *key)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't this a member of py::dict?

Copy link
Contributor Author

@virtuald virtuald Feb 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the code that is intended to call this (function dispatcher) uses the raw CPython API, presumably for performance reasons?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

@virtuald
Copy link
Contributor Author

Also, if someone could retrigger the checks for this, it's likely that the tests will pass.

#endif
}

inline PyObject * dict_getitem(PyObject *v, PyObject *key)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

throw error_already_set();
}

rv = PyDict_GetItemWithError(v, kv);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point, can't you just call dict_getitemstring?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I was thinking about calling your dict_getitem. From this line on, dict_getitemstring and dict_getitem are the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite the same, Py_DECREF needs to be called on the key before the error is thrown.

Copy link
Collaborator

@EricCousineau-TRI EricCousineau-TRI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great from my side! Just a minor nit on rationale comment. (Yeah, discoverable via git blame + clicks, but mayhaps a terse statement could help!)

@rwgk
Copy link
Collaborator

rwgk commented Jul 1, 2021

Hi Dustin, sorry for the long delay! This PR escaped me before. It looks very important.
Could you please rebase this PR to trigger the CI? That will run new clang-tidy checks we added last week.

@rwgk
Copy link
Collaborator

rwgk commented Jul 1, 2021

Nice, thanks! Good to see that the new clang-tidy is happy.

@rwgk
Copy link
Collaborator

rwgk commented Jul 1, 2021

I forgot to mention, I already integrated this PR for Google-internal global testing. I'll hold off merging until I get the results, later tonight if things go well.

@rwgk
Copy link
Collaborator

rwgk commented Jul 2, 2021

The Google-internal testing was successful. Merging!

@rwgk rwgk merged commit 6d44094 into pybind:master Jul 2, 2021
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Jul 2, 2021
@henryiii henryiii removed the needs changelog Possibly needs a changelog entry label Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants